home *** CD-ROM | disk | FTP | other *** search
/ AutoCAD Resource Guide / AutoCAD Resource Guide - ESX Interactive.ISO / title.mst < prev    next >
Encoding:
Text File  |  1994-11-01  |  14.3 KB  |  462 lines

  1. '**************************************************************************
  2. '*
  3. '* TITLE.MST - Viewer Runtime Setup Script
  4. '*
  5. '* CUSTOMIZING TITLE.MST
  6. '*
  7. '* For a simple Setup routine, you just need to assign values to the 
  8. '* series of variables following the heading "Setup Variables". This
  9. '* script also provides for the following more-advanced options, which
  10. '* are supported by subroutines located later in this script:
  11. '*
  12. '* Option                                         See Subroutine
  13. '* ------------------------------------------     ---------------------
  14. '* Install more than one .MVB file                ModifyViewerIni
  15. '* Install Help title                             ModifyViewerIni
  16. '* Install custom DLLs                            ModifyViewerIni
  17. '* Install multiple Program Manager items         ModifyProgramManager
  18. '* Display a custom icon with the ProgMan item    ModifyProgramManager
  19. '* Install custom fonts                           RegisterCustomFonts
  20. '* Install Video for Windows runtime files        RegisterDrivers
  21. '*
  22. '* Each customization note starts with the heading CUSTOMIZATION.
  23. '*
  24. '**************************************************************************
  25.     
  26.     '' Global variables
  27.  
  28.     GLOBAL TitleShortName$
  29.     GLOBAL TitleLongName$
  30.     GLOBAL MVBFileName$
  31.     GLOBAL PromptForPath%
  32.     GLOBAL DefaultPath$
  33.     GLOBAL ProgManGroup$
  34.     GLOBAL OtherProgManGroup$
  35.     GLOBAL ProgManItem$
  36.     GLOBAL szTitleDir$
  37.  
  38.     '' ****************************************************************
  39.     '' ** Setup Variables
  40.     '' ****************************************************************
  41.  
  42.     '' Set the following string to a short form of the title name
  43.     '' (for example, "Gallery")
  44.     
  45.     TitleShortName$ = "ARG"
  46.     
  47.     '' Set the following string to a long form of the title name
  48.     '' (for example, "Viewer 2.0 Gallery")
  49.     
  50.     TitleLongName$ = "AutoCAD Resource Guide"
  51.         
  52.     '' Set the following variable to the name of the MVB file, without 
  53.     '' the filename extension (for example, "GALLERY")
  54.         
  55.     MVBFileName$ = "argdb02"
  56.         
  57.     '' The following variable determines whether Setup prompts the user
  58.     '' to specify a directory in which to install title files. (Files
  59.     '' to be installed on the hard disk must be listed in the TITLE.INF 
  60.     '' file under the [Installed Title Files] section.) Specify one of
  61.     '' the following values:
  62.     ''
  63.     '' 0    Install title files in the Windows directory (default setting).
  64.     ''      This is an appropriate setting if you have a limited number
  65.     ''      of files to copy (for example, a single custom icon or DLL).
  66.     ''
  67.     '' 1    Display a dialog box to prompt the user for a directory in 
  68.     ''      which to install files
  69.         
  70.     PromptForPath% = 1
  71.         
  72.     '' If you have specified 1 in PromptForPath%, set the following 
  73.     '' variable to the default path that will be displayed in the dialog
  74.     '' box (for example, "C:\GALLERY").
  75.         
  76.     DefaultPath$ = "C:\ARG"
  77.     
  78.     '' Set the following variable to the name of the program manager 
  79.     '' group you would like to create (for example, "Viewer 2.0 Gallery")
  80.         
  81.     ProgManGroup$ = "AutoCAD Resource Guide"
  82.     
  83.     '' Set the following variable to the caption of the program manager 
  84.     '' item for your title (for example, "Gallery")
  85.         
  86.     ProgManItem$ = "AutoCAD Resource Guide Fall/Winter 1994"
  87.     
  88.     '***********************************************************************
  89.     '** Mainline
  90.     '***********************************************************************
  91.  
  92.     GLOBAL CUIDLL$
  93.  
  94.     '' Include files
  95.     '$INCLUDE 'setupapi.inc'
  96.     
  97.     '' Custom UI dll
  98.     CUIDLL$ = "mscuistf.dll"
  99.     
  100.     '' Dialog ID's
  101.     CONST DESTPATH      = 1000
  102.     CONST APPHELP       = 2000
  103.     CONST TOOBIG        = 3000
  104.     CONST BADPATH       = 4000
  105.     CONST SUCCESS       = 5000
  106.     
  107.     '' Bitmap ID
  108.     CONST LOGO = 1
  109.     
  110.     '' Functions and subroutines
  111.     DECLARE FUNCTION AddFont LIB "mscuistf.dll" (szFont$, szName$) AS INTEGER
  112.     DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  113.     DECLARE FUNCTION GetTitleDir (szDefault$) AS STRING
  114.     DECLARE FUNCTION CopyFiles(szTitleDir$) AS INTEGER
  115.     DECLARE SUB RegisterFont(fontfile$, fontname$)
  116.     DECLARE SUB ModifyViewerIni
  117.     DECLARE SUB RegisterCustomFonts
  118.     DECLARE SUB ModifyProgramManager
  119.     DECLARE SUB ShowSuccess
  120.     DECLARE SUB RegisterDrivers
  121.     
  122.     '' The following statement turns size checking off. Set it to scmOnFatal 
  123.     '' to enable size checking, where Setup will compare the disk file size 
  124.     '' with the INF file size and report an error if they are not the same.
  125.     
  126.     i% = SetSizeCheckMode(scmOff)
  127.     
  128.     '' Set the title and banner bitmap. You must rebuild MSCUISTF.DLL to 
  129.     '' alter the banner bitmap.
  130.     
  131.     SetTitle "Setup"
  132.     SetBitmap CUIDLL$, LOGO 
  133.     
  134.     '' Read in the INF file.
  135.     
  136.     ReadInfFile GetSymbolValue("STF_CWDDIR") + "TITLE.INF"
  137.     
  138.     '' Decide where to put title files
  139.     IF PromptForPath% = 1 THEN
  140.         szTitleDir$ = GetTitleDir(DefaultPath$)
  141.         IF szTitleDir$ = "" THEN
  142.             GOTO QUIT
  143.         ENDIF
  144.     ELSE
  145.         szTitleDir$ = GetWindowsDir()
  146.     ENDIF   
  147.     
  148.     '' Copy files
  149.     IF CopyFiles(szTitleDir$) = 0 THEN
  150.         GOTO QUIT
  151.     ENDIF
  152.  
  153.     '' Create the MVIEWER2.EXE MVB association 
  154.     CreateIniKeyValue "WIN.INI", "Extensions", "MVB", "mviewer2.exe", cmoNone
  155.  
  156.     '' Register in VIEWER.INI
  157.     ModifyViewerIni
  158.  
  159.     '' Register custom fonts
  160.     RegisterCustomFonts
  161.  
  162.     '' Register drivers
  163.     RegisterDrivers
  164.     
  165.     '' Modify Program Manager
  166.     ModifyProgramManager    
  167.     
  168. QUIT:
  169.     
  170.     END
  171.     
  172.  
  173. '*************************************************************************
  174. '** Purpose:
  175. '**     Prompts the user for a path for the title files
  176. '** Arguments:
  177. '**     szDefault$ - default path
  178. '** Returns:
  179. '**     New valid path name, or "" if the user quit.
  180. '*************************************************************************
  181.  
  182. FUNCTION GetTitleDir (szDefault$) STATIC AS STRING
  183.  
  184.     SetSymbolValue "String", TitleShortName$
  185.     SetSymbolValue "EditTextIn", szDefault$
  186.     SetSymbolValue "EditFocus", "ALL"
  187.                    
  188.     GETPATH:
  189.  
  190.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, "FHelpDlgProc")
  191.  
  192.     IF sz$ = "CONTINUE" THEN
  193.         szTitleDir$ = GetSymbolValue("EditTextOut")
  194.         IF IsDirWritable(szTitleDir$) = 0 THEN
  195.  
  196.             BADPATH:
  197.  
  198.             sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfoDlgProc", 0, "")
  199.             IF sz$ = "REACTIVATE" THEN
  200.                 GOTO BADPATH
  201.             END IF
  202.             UIPop 1
  203.             GOTO GETPATH
  204.         END IF
  205.         UIPop 1
  206.         CreateDir szTitleDir$, cmoNone
  207.  
  208.     ELSEIF sz$ = "REACTIVATE" THEN
  209.         GOTO GETPATH
  210.  
  211.     ELSE
  212.         szTitleDir$ = ""
  213.  
  214.     END IF
  215.  
  216.     GetTitleDir = szTitleDir$
  217.  
  218. END FUNCTION
  219.  
  220.  
  221. '*************************************************************************
  222. '** Purpose:
  223. '**     Copies the files in the INF file
  224. '** Arguments:
  225. '**     szTitleDir$ - destination directory for the title files
  226. '** Returns
  227. '**     1 if files were copied, 0 otherwise
  228. '*************************************************************************
  229.  
  230. FUNCTION CopyFiles(szTitleDir$) STATIC AS INTEGER
  231.  
  232.     '' Add all system files to the copy list
  233.     AddSectionFilesToCopyList "System Files", GetSymbolValue("STF_SRCDIR"), GetWindowsSysDir()
  234.     
  235.     '' Add all of the title files to the copy list
  236.     AddSectionFilesToCopyList "Installed Title Files", GetSymbolValue("STF_SRCDIR"), szTitleDir$
  237.     
  238.     '' Check size
  239.     szExtras$ = "Extra"
  240.     szCosts$ = "Costs"
  241.     szNeededs$ = "Neededs"
  242.     FOR i% = 1 TO 26 STEP 1
  243.         AddListItem szExtras$, "0"
  244.     NEXT i%
  245.     
  246.     '' We assume that VIEWER.INI will take another 4K
  247.     ReplaceListItem szExtras$, ASC(MID$(UCASE$(GetWindowsDir()), 1, 1)) - ASC("A") + 1, STR$(4096)
  248.     '' Get amount of space required
  249.     StillNeed& = GetCopyListCost(szExtras$, szCosts$, szNeededs$)
  250.     
  251.     '' Put up a message if there is not enough space
  252.     FOR i% = 1 TO 26 STEP 1
  253.         IF VAL(GetListItem(szNeededs$, i%)) > 0 THEN
  254.     
  255.             SetSymbolValue "String1", LTRIM$(STR$(VAL(GetListItem(szCosts$, i%)) / 1024))
  256.             SetSymbolValue "String2", CHR$(i% - 1 + ASC("A"))
  257.     
  258.             TOOBIG:
  259.     
  260.             sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfoDlgProc", 0, "")
  261.             IF sz$ = "REACTIVATE" THEN
  262.                 GOTO TOOBIG
  263.             END IF
  264.             UIPop 1
  265.             CopyFiles = 0
  266.             GOTO DONTCOPY
  267.         END IF
  268.     NEXT i%
  269.     
  270.     '' Copy the files
  271.     CopyFilesInCopyList
  272.     
  273.     CopyFiles = 1
  274.  
  275. DONTCOPY:
  276.  
  277. END FUNCTION
  278.  
  279.  
  280. '*************************************************************************
  281. '** Purpose:
  282. '**     Puts up a success dialog
  283. '*************************************************************************
  284.  
  285. SUB ShowSuccess STATIC
  286.  
  287.     SUCCESS:
  288.     
  289.     SetSymbolValue "String1", TitleShortName$
  290.     sz$ = UIStartDlg(CUIDLL$, SUCCESS, "FInfoDlgProc", 0, "")
  291.     IF sz$ = "REACTIVATE" THEN
  292.         GOTO SUCCESS
  293.     END IF
  294.     UIPop 1
  295.     
  296. END SUB
  297.  
  298.  
  299. '*************************************************************************
  300. '** Purpose:
  301. '**     Appends a file name to the end of a directory path,
  302. '**     inserting a backslash character as needed.
  303. '** Arguments:
  304. '**     szDir$  - full directory path (with optional ending "\")
  305. '**     szFile$ - filename to append to directory
  306. '** Returns:
  307. '**     Resulting fully qualified path name.
  308. '*************************************************************************
  309.  
  310. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  311.     IF szDir$ = "" THEN
  312.         MakePath = szFile$
  313.     ELSEIF szFile$ = "" THEN
  314.         MakePath = szDir$
  315.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  316.         MakePath = szDir$ + szFile$
  317.     ELSE
  318.         MakePath = szDir$ + "\" + szFile$
  319.     END IF
  320. END FUNCTION
  321.  
  322.  
  323. '*************************************************************************
  324. '** Purpose:
  325. '**     Registers a font.
  326. '** Arguments:
  327. '**     fontfile$ - font filename
  328. '**     fontname$ - font name.
  329. '*************************************************************************
  330.  
  331. SUB RegisterFont(fontfile$, fontname$) STATIC
  332.  
  333.     '' A simple error catching wrapper around AddFont, which is a 'C' routine in MSCUISTF.DLL
  334.  
  335.     IF AddFont(fontfile$, fontname$) = -1 THEN
  336.         j% = DoMsgBox("Could not install " + fontfile$ + " font.", "Viewer Font Installation", 0)
  337.     ENDIF
  338.  
  339. END SUB
  340.  
  341.  
  342. '*************************************************************************
  343. '** Purpose:
  344. '**     Registers title in VIEWER.INI
  345. '*************************************************************************
  346.  
  347. SUB ModifyViewerIni STATIC
  348.  
  349.     '' Get the VIEWER.INI file
  350.     
  351.     szIni$ = MakePath(GetWindowsDir(), "VIEWER.INI")
  352.  
  353.     '' First register the title file, setting the Name and Path entries. 
  354.     '' We assume that the MVB file is the same directory as SETUP.EXE.
  355.     ''
  356.     '' CUSTOMIZATION: If you're installing multiple MVB files, copy the
  357.     '' following two statements for each additional file, substituting
  358.     '' the appropriate long name and MVB filename for the TitleLongName$
  359.     '' and MVBFileName$ variables.
  360.     
  361.     CreateIniKeyValue szIni$, MVBFileName$, "Name", TitleLongName$, cmoOverwrite
  362.     CreateIniKeyValue szIni$, MVBFileName$, "Path", GetSymbolValue("STF_SRCDIR"), cmoOverwrite
  363.     
  364.     '' Now we have to register the MVB file in the [FILES] section, so 
  365.     '' Viewer can find files that are not on the path and display a 
  366.     '' special message when a file is not found.
  367.  
  368.     CreateIniKeyValue szIni$, "FILES", MVBFileName$ + ".MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the " + TitleLongName$ + " disk.", cmoOverwrite
  369.  
  370.     '' CUSTOMIZATION: If you're installing a Help title or any custom DLLs,
  371.     '' you should copy the preceding statement for each extra title or DLL.
  372.     ''
  373.     '' Example for installing an extra title:
  374.     ''
  375.     ''    CreateIniKeyValue szIni$, "FILES", "GALHELP.MVB", GetSymbolValue("STF_SRCDIR") + "," + "Please insert the Viewer 2.0 Gallery disk.", cmoOverwrite
  376.     ''
  377.     '' Example for installing a custom DLL:
  378.     ''
  379.     ''    CreateIniKeyValue szIni$, "FILES", "GALLERY.DLL", GetSymbolValue("STF_SRCDIR") + "," + "A required file is missing. Please reinstall the Viewer Gallery.", cmoOverwrite
  380.  
  381. END SUB
  382.  
  383.  
  384. '*************************************************************************
  385. '** Purpose:
  386. '**     Creates program manager entries for the title
  387. '*************************************************************************
  388.  
  389. SUB ModifyProgramManager STATIC
  390.  
  391.     '' Create the program manager groups
  392.  
  393.     CreateProgmanGroup ProgmanGroup$, "", cmoNone
  394.     ShowProgmanGroup ProgmanGroup$, 1, cmoNone
  395.     
  396.     '' Create entries for the title, demos
  397.  
  398.     CreateProgmanItem ProgmanGroup$, ProgmanItem$, "mviewer2.exe " + MakePath(GetSymbolValue("STF_SRCDIR"), MVBFileName$ + ".MVB"), MakePath(szTitleDir$,"arg.ico,0,,,")+GetSymbolValue("STF_SRCDIR"), cmoOverwrite
  399.     
  400. END SUB
  401.  
  402.  
  403. '*************************************************************************
  404. '** Purpose:
  405. '**     Registers custom fonts with Windows.
  406. '*************************************************************************
  407.  
  408. SUB RegisterCustomFonts STATIC
  409.  
  410.     '' CUSTOMIZATION: If you install custom fonts, then add statements
  411.     '' in this routine to register the fonts with the current Windows 
  412.     '' session and to add them to the WIN.INI [Fonts] section. 
  413.     ''
  414.     '' Note that TrueType fonts can only be installed in Windows 3.1.
  415.     '' RegisterFont automatically creates the required .FOT file for 
  416.     '' TrueType fonts.
  417.     ''    
  418.     '' The following example registers a font residing in MISTRAL.TTF
  419.     '' and installs the font with the name Mistral (True Type):
  420.     '' 
  421.     ''     RegisterFont "mistral.ttf", "Mistral (TrueType)"
  422.     ''
  423.  
  424. END SUB
  425.  
  426.  
  427. '*************************************************************************
  428. '** Purpose:
  429. '**     Registers Windows drivers
  430. '*************************************************************************
  431.  
  432. SUB RegisterDrivers STATIC
  433.  
  434. '' CUSTOMIZATION: Video for Windows is not a standard component of
  435. '' Windows 3.1. If your title uses video, proceed as follows.
  436. ''
  437. '' 1) Add the following files to the [System Files] section of the INF file:
  438. ''
  439. ''    dispdib.dll
  440. ''    msvideo.dll
  441. ''    indeo.drv
  442. ''    mciavi.drv
  443. ''    msvidc.drv
  444. ''
  445. '' 2) Add the above files to your release directory. US versions can be 
  446. ''    found in the \SYSTEM subdirectory of your Viewer disc. French and
  447. ''    German versions were not available at ship time. Please contact 
  448. ''    Microsoft or check the Multimedia Viewer section on the Microsoft
  449. ''    Compuserve Forum for further details.
  450. ''
  451. '' 3) Uncomment the following lines:
  452. ''
  453. '' CreateIniKeyValue "WIN.INI", "mci extensions", "AVI", "AVIVIDEO", cmoNone
  454. '' CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "mci", "AVIVIDEO", "MCIAVI.DRV", cmoNone
  455. '' CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "drivers", "vidc.msvc", "msvidc.drv", cmoNone
  456. '' CreateIniKeyValue MakePath(GetWindowsDir(), "SYSTEM.INI"), "drivers", "vidc.rt21", "indeo.drv", cmoNone
  457.  
  458. END SUB
  459.  
  460.  
  461.  
  462.